x86/NUMA: correct off-by-1 in node map size calculation
authorJan Beulich <jbeulich@suse.com>
Fri, 30 Sep 2022 07:55:34 +0000 (09:55 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 30 Sep 2022 07:55:34 +0000 (09:55 +0200)
commitb1f4b45d02cac2bf704c2fcc61c70c3567cfaa5b
treebbf017d4346d4373cc2e062adc469ce7b335ae78
parentdefa4e51d20a143bdd4395a075bf0933bb38a9a4
x86/NUMA: correct off-by-1 in node map size calculation

extract_lsb_from_nodes() accumulates "memtop" from all PDXes one past
the covered ranges. Hence the maximum address which can validly by used
to index the node map is one below this value, and we may currently set
up a node map with an unused (and never initialized) trailing entry. In
boundary cases this may also mean we dynamically allocate a page when
the static (64-entry) map would suffice.

While there also correct the comment ahead of the function, for it to
match the actual code: Linux commit 54413927f022 ("x86-64:
x86_64-make-the-numa-hash-function-nodemap-allocation fix fix") removed
the ORing in of the end address before we actually cloned their code.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Wei Chen <Wei.Chen@arm.com>
xen/arch/x86/numa.c